﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using ElectronicJournal.DB.Item;

namespace ElectronicJournal.Account.EditorAccount
{
    public partial class Publications : System.Web.UI.Page
    {
        //private List<ItemPublication> PublicationsList;

        protected void Page_Load(object sender, EventArgs e)
        {
            /*DB.DbPublications db = new DB.DbPublications();
            PublicationsList = db.GetUnreadPublicationsForEditor(Membership.GetUser().ProviderUserKey.ToString());
            GridView1.DataSource = PublicationsList;
            GridView1.DataBind();*/
        }

        protected void LinkButton_Click(object sender, EventArgs e)
        {
            GridView1.Visible = true;
            PublicationPanel.Visible = false;
            CurrentPublicationId.Text = "";
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            /*ItemPublication CurrentPublication = new DB.DbPublications().GetPublication(GridView1.SelectedDataKey.Value.ToString());
            UploaderLabel.Text = new DB.DbPublications().GetUserName(CurrentPublication.Uploader);
            AuthorLabel.Text = CurrentPublication.Author;
            TitleLabel.Text = CurrentPublication.Title;
            FileLinkButton.Text = CurrentPublication.FileName.Remove(0, CurrentPublication.FileName.LastIndexOf("\\") + 1);
            ReviewerLabel.Visible = CurrentPublication.Reviewer != "";
            if (ReviewerLabel.Visible) ReviewerLabel.Text = new DB.DbPublications().GetUserName(CurrentPublication.Reviewer);
            ReviewersPanel.Visible = CurrentPublication.Reviewer == "";
            ReviewPanel.Visible = CurrentPublication.IsReadByReviewer;
            ReviewTextBox.Text = CurrentPublication.Review;
            SendButton.Visible = CurrentPublication.IsReadByReviewer;
            GridView1.Visible = false;
            PublicationPanel.Visible = true;*/
        }

        protected void ReviewersButton_Click(object sender, EventArgs e)
        {
           /* DB.DbPublications db = new DB.DbPublications();
            db.SendPublicationToReviewer(ReviewersDropDownList.SelectedValue, CurrentPublicationId.Text);
            Response.Redirect("~/Editor/Publications.aspx");*/
        }

        protected void FileLinkButton_Click(object sender, EventArgs e)
        {
            /*WebClient client = new WebClient();
            ItemPublication CurrentPublication = new DB.DbPublications().GetPublication(GridView1.SelectedDataKey.Value.ToString());
            Byte[] buffer = client.DownloadData(CurrentPublication.FileName);
            if (buffer != null)
            {
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-length", buffer.Length.ToString());
                Response.BinaryWrite(buffer);
            }*/
        }
    }
}